package com.hk.yajin.view;

import android.content.Context;
import android.media.MediaPlayer;
import android.util.AttributeSet;
import android.widget.VideoView;

/**
 * Created by 伦哥哥 on 2017/7/6.
 */

public class MyVideoView extends VideoView {

    public MyVideoView(Context context) {
        super(context);
    }

    public MyVideoView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public MyVideoView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    public void setOnHandleVideoView(OnHandleVideoView onHandleVideoView) {
        this.onHandleVideoView = onHandleVideoView;
    }

    private OnHandleVideoView onHandleVideoView;

    @Override
    public void start() {
        super.start();
        if (onHandleVideoView != null) {
            onHandleVideoView.onPlayStart();
        }
    }

    @Override
    public void pause() {
        super.pause();
        if (onHandleVideoView != null) {
            onHandleVideoView.onPlayPause();
        }
    }


    @Override
    public void stopPlayback() {
        super.stopPlayback();
        if (onHandleVideoView != null) {
            onHandleVideoView.onPlayStopPlayback();
        }
    }


    public interface OnHandleVideoView {

        void onPlayStart();

        void onPlayPause();

        void onPlayStopPlayback();

    }
}
